package cn.iocoder.yudao.module.trade.framework.delivery.config;

import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * ExpressClientEnum 的自定义转换器
 */
@Component
@ConfigurationPropertiesBinding
public class ExpressClientConverter implements Converter<String, ExpressClientEnum> {

    @Override
    public ExpressClientEnum convert(String source) {
        if (source == null || source.isEmpty()) {
            return ExpressClientEnum.NOT_PROVIDE;
        }
        
        for (ExpressClientEnum value : ExpressClientEnum.values()) {
            if (value.getCode().equalsIgnoreCase(source)) {
                return value;
            }
        }
        
        return ExpressClientEnum.NOT_PROVIDE;
    }
} 